<?php
class ControllerFeedGoogleSitemap extends AdminController {

	public function index() {
		$this->document->setTitle($this->_['heading_title']);

		if ($this->request->isPost() && $this->validate()) {
			M('setting/setting');

			$this->model_setting_setting->editSetting('google_sitemap', $this->request->post);

			$this->session->set_flashdata('success', $this->_['text_success']);
			$this->redirect(UA('extension/feed'));
		}
		
		//bread crumbs
		$this->data['breadcrumbs'] = array();
		$this->data['breadcrumbs'][] = array(
				'text'      => $this->_['text_home'],
				'href'      => UA('common/home'),
				'separator' => false
		);
		
   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->_['text_feed'],
			'href'      => UA('extension/feed'),
      		'separator' => ' :: '
   		);

   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->_['heading_title'],
			'href'      => UA('feed/google_sitemap'),
      		'separator' => ' :: '
   		);


		if (isset($this->request->post['google_sitemap_status'])) {
			$this->data['google_sitemap_status'] = $this->request->post['google_sitemap_status'];
		} else {
			$this->data['google_sitemap_status'] = C('google_sitemap_status');
		}

		$this->data['data_feed'] = U('feed/google_sitemap');

		$this->display('feed/google_sitemap.tpl');
	}

	protected function validate() {
		if (!$this->hasMP()) {
			$this->setMessage('error_warning', $this->_['error_permission']);
			return false;
		}
		return true;
	}
}
?>